package algorithm;

public class ArrayMaxFinder<T extends Comparable<T>> {
public T findMax(T[] array){
    if(array==null||array.length==0){
        throw new IllegalArgumentException("数组不能为nluu或空");
    }
    T max=array[0];
    for(int i=0;i<array.length;i++){
        if(array[i].compareTo(max)>0){
            max=array[i];
        }
    }
    return max;
}

    public static void main(String[] args) {
        ArrayMaxFinder<Integer> a = new ArrayMaxFinder<Integer>();
        Integer[] arr = {1,2,3,4,5,6,7,8,9,10};
        System.out.println(a.findMax(arr));

        ArrayMaxFinder<String>stringFinder=new ArrayMaxFinder<>();
        String[] word={"apple","banana"};
        System.out.println(stringFinder.findMax(word));
 }
}
